package cc.fine.svc.main.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

@Component
public class SecurityUtils {

    @Autowired
    private PasswordEncoder passwordEncoder;

    /**
     * 生成秘钥
     */
    public String getSecret(String password) {
        return passwordEncoder.encode(password);
    }

    /**
     * 判断秘钥与明文是否匹配
     */
    public boolean match(String password, String secret) {
        return passwordEncoder.matches(password, secret);
    }
}
